<?php
/**
 * *********************************************************************************************************************
 * 中通巴枪pda soa
 * *********************************************************************************************************************
 */
namespace soa\parter\zt;
use soa\client;

class pda extends client
{
    /**
     * 服务地址
     * @var string
     */
    public $service_url = 'http://express.core.kuaidihelp.com/';
    /**
     * 服务名称
     * @var string
     */
    public $service_name = 'kuaidihelp_express';

    /**
     * 获取快递员的巴枪信息
     * @param $account
     * @return string
     */
    public function login($account)
    {
        if(empty($account) || !is_array($account)) {
            return '';
        }
//        return $this->get('v1/pda/zt/login', array('account' => $account));
        $this->service_url = 'http://pda.core.kuaidihelp.com/';
        $this->service_name = 'kuaidihelp_pda';
        return $this->get('v1/partner/Zt/login', array('account' => $account));
    }

    /**
     * 上传签收图片
     * @param $account
     * @param $wayBillNo
     * @param $img
     * @param $guid
     * @param $openId
     * @return bool|string
     */
    public function uploadSignPic($account, $wayBillNo, $img, $guid, $openId)
    {
        if(empty($account) || empty($wayBillNo) || empty($img) || empty($guid))
            return false;

        $result = $this->post('v1/pda/zt/uploadPic', array(
            'account' => $account,
            'wayBillNo' => $wayBillNo,
            'img' => $img,
            'guid' => $guid,
            'type' => 1,
            'openId' => $openId
        ));


        if(isset($result['Success']))
            return true;
        elseif(isset($result['error']))
            return $result['error']['reason'];
        else
            return false;
    }

    /**
     * 上传问题件图片
     * @param $account
     * @param $wayBillNo
     * @param $img
     * @param $guid
     * @param $openId
     * @return bool|string
     */
    public function uploadBadPic($account, $wayBillNo, $img, $guid, $openId)
    {
        if(empty($account) || empty($wayBillNo) || empty($img) || empty($guid))
            return false;

        $result = $this->post('v1/pda/zt/uploadPic', array(
            'account' => $account,
            'wayBillNo' => $wayBillNo,
            'img' => $img,
            'guid' => $guid,
            'type' => 2,
            'openId' => $openId
        ));

        if(isset($result['Success']))
            return true;
        elseif(isset($result['error']))
            return $result['error']['reason'];
        else
            return false;
    }

    /**
     * 巴枪扫描数据入库
     * @param $values
     * @return bool
     */
    public function logScanData($values)
    {
        if(empty($values) || !is_array($values))
            return false;

        return $this->post('v1/pda/zt/insertPdaData', array('values' => $values));
    }

    /**
     * clone 巴枪扫描数据入库
     * @param $values
     * @return bool
     */
    public function cloneScanData($values)
    {
        if(empty($values) || !is_array($values))
            return false;

        return $this->post('v1/pda/zt/clonePdaData', array('values' => $values));
    }

    /**
     * 用户实名信息上传
     * @param $account
     * @return string
     */
    public function uploadRealName($account,$data)
    {
        if(empty($account) || !is_array($account) || empty($data) || !is_array($data)) {
            return '';
        }
        return $this->post('v1/pda/zt/uploadRealName', array('account' => $account,'data'=>$data));
    }

    /**
     * 全国用户实名信息上传
     * @param $account
     * @return string
     */
    public function uploadRealNameOfZt($account,$data)
    {
        if(empty($account) || !is_array($account) || empty($data) || !is_array($data)) {
            return '';
        }

        return $this->post('v1/pda/zt/uploadRealNameOfZt', array('account' => $account,'data'=>$data));
    }

    /**
     * 全国寄收信息上传
     * @param $account
     * @return string
     */
    public function uploadSenderReceiveCountryOfZt($account,$data)
    {
        if(empty($account) || !is_array($account) || empty($data) || !is_array($data)) {
            return '';
        }

        return $this->post('v1/pda/zt/uploadSenderReceiveCountryOfZt', array('account' => $account,'data'=>$data));
    }

}